using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using static Cinemachine.DocumentationSortingAttribute;

public class HUD : MonoBehaviour
{
    public enum InfoType
    {
        Exp,Level,Kill,Time,Health
    }
    public InfoType type;
    private Text myText;
    private Slider mySlider;

    private void Awake()
    {
        myText = GetComponent<Text>();
        mySlider = GetComponent<Slider>();
    }
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        switch (type)
        {
            case InfoType.Exp:
                float curExp = GameManager.instance.exp;
                float maxExp = GameManager.instance.nextExp[Mathf.Min(GameManager.instance.level, GameManager.instance.nextExp.Length - 1)];
                mySlider.value = curExp / maxExp;
                break;
            case InfoType.Level:
                myText.text ="Lv." + GameManager.instance.level;
                break;
            case InfoType.Kill:
                myText.text = GameManager.instance.kill.ToString();
                break;
            case InfoType.Time:
                float gameTime = GameManager.instance.gameTime;
                int min =Mathf.FloorToInt(gameTime / 60);
                int sec =Mathf.FloorToInt(gameTime % 60);
                myText.text =string.Format("{0:D2}:{1:D2}",min,sec); 
                break;
            case InfoType.Health:
                float curHealth = GameManager.instance.health;
                float maxHealth = GameManager.instance.maxHealth;
                mySlider.value = curHealth / maxHealth;
                break;
        }
    }
}
